import unittest
import cvebot


class CVEBotTest(unittest.TestCase):
    # def test_get_cve_patch_subject(self):
    #     cves = ['CVE-2022-49889', 'CVE-2025-37780']
    #     expects = [
    #         'ring-buffer: Check for NULL cpu_buffer in ring_buffer_wake_waiters()',
    #         'isofs: Prevent the use of too small fid'
    #     ]
    #     for cve, expect in zip(cves, expects):
    #         subject = cvebot.get_cve_patch_subject(cve)
    #         self.assertEqual(subject, expect)

    # def test_has_git_log_cache(self):
    #     self.assertTrue(cvebot._has_git_log_cache(cvebot.MAINLINE_DIR, cvebot.BRANCH_MASTER))
    #     self.assertTrue(cvebot._has_git_log_cache(cvebot.OH_LINUX_DIR, cvebot.BRANCH_503))

    # def test_check_affected_branches(self):
    #     subjects = [
    #         'isofs: Prevent the use of too small fid',
    #         'bluetooth/l2cap: sync sock recv cb and release'
    #     ]
    #     expects = [
    #         [cvebot.BRANCH_MASTER, cvebot.BRANCH_503],
    #         []
    #     ]
    #     for sub, exp in zip(subjects, expects):
    #         self.assertListEqual(cvebot.check_affected_branches(sub), exp)

    # def test_fix_branch(self):
    #     patch_path = "/Volumes/Coding/ohscript/CVE-2025-22057-3a0a3ff6593d.patch"
    #     self.assertFalse(cvebot.fix_branch(cvebot.BRANCH_MASTER, patch_path))

    # def test_get_issue(self):
    #     self.assertEqual('ICF8GA', cvebot.get_issue(cvebot.BRANCH_MASTER))
    #     self.assertEqual('ICF8GG', cvebot.get_issue(cvebot.BRANCH_503))

    def test_rename_patch(self):
        patch_path = "/Volumes/Coding/ohscript/CVE-2025-37808-dcc47a028c24.patch"
        expect = "/Volumes/Coding/ohscript/CVE-2025-37808-dcc47a028c24.issue.patch"
        self.assertEqual(cvebot._rename_patch(patch_path, 'issue'), expect)


if __name__ == '__main__':
    unittest.main()